package org.grow.sha.service;

import org.grow.sha.entity.Account;
import org.grow.sha.serviceAop.BackMenuException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.awt.*;

@Component
public class TaskExeService {
    @Autowired
    private RedActivity redActivity;
    @Autowired
    private GreenActivity greenActivity;
    @Autowired
    private BlueActivity blueActivity;
    //    @Value("${app.content:higuozi}")
//    private String content;
    Logger logger = LoggerFactory.getLogger(TaskExeService.class);
    public static final Color mainmenu = new Color(73, 18, 16);
    public static final Point corePoint = new Point(201, 656);
    //    800buxing
    public static final Point relaxPoint = new Point(1000, 656);

    public void doingtasks(Account account){
//        //    0代表不执行本任务 1代表执行刷蛋任务和扫荡任务,
////    2代表只执行刷蛋任务不扫荡,3代表执行升级通关任务不扫荡
        greenActivity.sprintTask(account);
        switch (account.getEggTaskLevel()) {
            case 0: {
                logger.info(account.getUsername() + "跳过紫蛋环节");
                break;
            }
            case 1: {
                greenActivity.purpleEgg(account, false, true);
                break;
            }
            case 2: {
                greenActivity.purpleEgg(account, false, false);
                break;
            }
            case 3: {
                greenActivity.purpleEgg(account, true, false);
                break;
            }
            default: {
                logger.info("config error");
            }
        }
//    0代表不执行任务 1代表执行任务并刷一次,2代表执行任务并刷两次．．．dailyWarLevel=0;
        if (account.getDailyWarLevel() == 0) {
            logger.info(account.getUsername() + "跳过武将列传环节");
        } else {
            blueActivity.dailyWar(account);
//
        }
//    0代表不打开工会页面操作　１代表打开页面操作unionLevel=2;
        switch (account.getUnionLevel()) {
            case 0: {
                logger.info(account.getUsername() + "跳过公会擂鼓等环节");
                break;
            }
            case 1: {
                redActivity.unionAbout(account);
                break;
            }
            default: {
                logger.info("config error");
            }
        }
//    0代表不将印开箱子　升阶武将　1代表试图开箱子并一定升阶　2代表试图开箱子但不升阶　sealLevel=1;
        switch (account.getSealLevel()) {
            case 0: {
                logger.info(account.getUsername() + "跳过将印和升阶环节");
                break;
            }
            case 1: {
                blueActivity.tagAbout(account, true);

                break;
            }
            case 2: {
                blueActivity.tagAbout(account, false);
                break;
            }
            default: {
                logger.info("config ,error");
            }
        }
//    0代表不开三国秀　１代表试图开三国秀elegantLevel=0;
        if (account.getElegantLevel() == 0) {
            logger.info(account.getUsername() + "跳过三国秀环节");
        } else {
            redActivity.elegantAbout(account);
        }
//    进行其他杂乱的活动　如世界发言　赠送鲜花　;
//        设计位运算             0/1       0/1
//        0 表示都不做 1表示仅仅赠送鲜花 2 表示仅仅世界发言 3表示二者都做
        int o = Integer.parseInt(account.getOtherTaskLevel(), 2);
        if ((o & 0b10) == 0b10) {
            redActivity.speech(account, account.getSpeechContent());
        }
        if ((o & 0b01) == 0b01) {
            redActivity.flowerPresent(account);
        }
//        每日签到领奖 0代表智能签到 1代表签到第一个条目 2代表签到第二个条目
//    每日签到领奖dailySignLevel=1;
//        if (account.getDailySignLevel() == 0) {
//            logger.info(account.getUsername() + "跳过日常签到");
//        } else {
//            greenActivity.dailySign(account, 10);
//        }
        switch (account.getDailySignLevel()) {
            case 0: {
                logger.info(account.getUsername() + "跳过日常签到");
                break;
            }
            case 1: {
                greenActivity.dailySign(account,1);
                break;
            }
            case 2: {
                greenActivity.dailySign(account,2);
                break;
            }
            default: {
                greenActivity.dailySign(account, 10);
            }
        }
//　　领取活跃奖励dailyActiveLevel = 1;
        if (account.getDailyActiveLevel() == 0) {
            logger.info(account.getUsername() + "跳过领取各种小奖励");
        } else {
            greenActivity.getReward(account);
        }

    }
}
